package com.wc.alorithm_luogu.P2615;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/21 12:47
 * @description https://www.luogu.com.cn/problem/P2615
 * 神奇的幻方
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[][] map = new int[n][n];

        int num = 1;
        // 首先将 1 写在第一行的中间。
        map[0][n / 2] = num;

        int max = n * n;

        int preRow = 0;

        int preCol = n / 2;

        while (num < max) {
            num++;

            if (preRow == 0 && preCol != (n - 1)) {
                preRow = n - 1;
                preCol = preCol + 1;
            } else if (preRow != 0 && preCol == n - 1) {
                preRow = preRow - 1;
                preCol = 0;
            } else if (preRow == 0 && preCol == n - 1) {
                preRow = preRow + 1;
            } else if (preRow != 0 && preCol != n - 1) {
                preRow = preRow - 1;
                preCol = preCol + 1;
                if (map[preRow][preCol] != 0) {
                    preRow = preRow + 2;
                    preCol = preCol - 1;
                }
            }

            map[preRow][preCol] = num;
        }

        for (int i = 0; i < n; i++) {
            System.out.print(map[i][0]);
            for (int j = 1; j < n; j++) {
                System.out.print(" " + map[i][j]);
            }
            System.out.println();
        }
    }
}
